package net.println.kotlin.chapter3

const val FINAL_HELLO_WORLD = "helloWorld"
var helloWorld = FINAL_HELLO_WORLD

fun main(args: Array<String>) {
//    checkArgs(args)
//    val aInt = args[0].toInt()
//    val bInt = args[1].toInt()
//    println("$aInt + $bInt = ${sum(aInt, bInt)}")
//    println(int2Long(5))
//    println(sum(2, 3))
//    println(sum.invoke(2,3))

//    args.forEach forEach@{
//        if (it == "q") return@forEach
//        println(it)
//    }
//    println("print end")

    println(sum)
    println(int2Long)
    println(::printUsage is () -> Unit)
}

val sum = { a: Int, b: Int ->
    println("$a + $b = ${a + b}")
    a + b
}
//(Int,Int) -> Int

fun checkArgs(args: Array<String>) {
    if (args.size != 2) {
        println("参数不匹配")
        System.exit(0)
    }
}

fun printUsage() {
    println("参数不匹配")//(Any?) -> Unit
}//() -> Unit

val int2Long = fun(x: Int) = x.toLong()